<?php
/**
 * Created by PhpStorm.
 * User: 陈立强
 * Date: 2019/9/9
 * Time: 9:36
 */
/**
 * 商家管理逻辑层
 * @author maniac
 */
namespace app\common\logic;

use app\common\model\Stores as StoresModel;

class Stores extends Base
{
    /**
     * 重组请求信息
     * @param  array $data 请求的信息
     * @return array
     */
    public function recombine($data)
    {
        if (empty($data['name'])){
            exception('请填写门店名称');
        }
        return $data;
    }


    /**
     * 拒绝
     */
    public function refuse($data){
        $StoresModel= new StoresModel();

        $save_data=[
            'id'=>$data['id'],
            'remark'=>$data['refuse_txt'],
            'status'=>2,
        ];

        $res=$StoresModel->isUpdate(true)->save($save_data);
        if($res){
            //生成操作日志
            $save_data['id']=$save_data['id'].'name=拒绝';
            $this->insertLog('app\common\model\Stores',$save_data);
            return $error_arr=[ 'code'=>1,'msg'=>'成功!'];
        }else{
            return $error_arr=[ 'code'=>0,'msg'=>'失败!'];
        }
    }
}